package cn.nnb.biz;

import cn.nnb.dao.UserDao;
import cn.nnb.pojo.User;
import cn.nnb.util.Log;


public class UserBiz {
	
	private  UserDao dao = new UserDao(); 
	public User login(String uname,String pwd) throws Exception{		
		User user = null;
		if(uname != null && pwd != null && !uname.equals("") && !pwd.equals(""))
		{
			UserDao dao = new UserDao();
			try{
				user = dao.login(uname, pwd);
			} catch (Exception e) {
				Log.logger.error(e.getMessage());
				throw e;
			}finally{
				dao.closeResource();
			}			
			
		}
		
		return user;
	}

	public User getUser(String uno) {
		try {
			return dao.getUser(uno);
		} catch (Exception e) {
			e.printStackTrace();
			return null ;
		}finally{
			dao.closeResource();
		}
	}
	public boolean register(User user)  {
		try {
			return dao.register(user);
		} catch (Exception e) {
			e.printStackTrace();
			return false ;
		}finally{
			dao.closeResource();
		}
	}
	
	public boolean UserExist(String uname) {
		try {
			return dao.UserExist(uname);
		} catch (Exception e) {
			e.printStackTrace();
			return false ;
		}finally{
			dao.closeResource();
		}
	}
	public int getN0() {
		try {
			return dao.getN0();
		} catch (Exception e) {
			e.printStackTrace();
			return -1 ;
		}finally{
			dao.closeResource();
		}
	}
}
